package net.pulseproject.router.app.view;

enum MenuItemType {
	
	QUIT { @Override public void callback(final MainMenuBarListener listener) {
		listener.onQuit(); }},
	
	PREFERENCES { @Override public void callback(final MainMenuBarListener listener) {
		listener.onPreferences(); }},
	
	AVAILABLE_PORTS { @Override public void callback(final MainMenuBarListener listener) {
		listener.onToggleAvailablePortsWindow(); }};
	
	
	public abstract void callback(final MainMenuBarListener listener);
	
	public static MenuItemType byName(final String name) {
		if(name == null) { throw new IllegalArgumentException("name == null"); }
		if(name.isEmpty()) { throw new IllegalArgumentException("name is empty!"); }
		
		for (final MenuItemType currentType : MenuItemType.values()) {
			if(currentType.name().equals(name)) {
				return currentType;
			}
		}
		throw new RuntimeException("Could not get MenuItemType by name [" + name + "]!");
	}
}
